<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

</h:head>
<body>
	<h:form id="frmCadSetor">
		<br />
		<h3 style="margin-top: 0">CADASTRO DE SETOR</h3>
		<div align="left">

			<p:commandButton value="Novo" actionListener="#{setorBean.novo}"
				ajax="grid" />

			<p:commandButton value="Salvar" disabled="#{setorBean.sal}"
				actionListener="#{setorBean.salvar}" ajax="grid" />

			<p:commandButton value="Alterar" disabled="#{setorBean.alt}"
				actionListener="#{setorBean.alterar}" ajax="grid" />

			<p:commandButton value="Excluir" disabled="#{setorBean.rem}"
				actionListener="#{setorBean.remover}" ajax="grid" />

			<p:commandButton id="consulta" value="Consulta"
				action="#{pesquisaSetorBean.abrirDialogo}">
				<p:ajax event="dialogReturn" listener="#{setorBean.setorSelecionado}" update="frmCadSetor"/>
			</p:commandButton>

			<p:commandButton value="Cancelar"
				actionListener="#{setorBean.cancelar}" ajax="grid" />
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />


			<h:panelGrid id="grid" columns="2" columnClasses="label, value">
				
					Código do Setor:
					<p:inputText id="idGrup" disabled="true"
					value="#{setorBean.setor.idSetor}" />
		
					Descrição:
					<p:inputText id="desc" value="#{setorBean.setor.descricao}"
					maxlength="100" size="30" disabled="#{setorBean.desc}" />

				<p:commandButton id="vincGripo" value="Incluir Grupo"
					disabled="#{setorBean.vig}" onclick="PF('dlg2').show();" />

			</h:panelGrid>

			<h:panelGrid id="gridData1" columns="1">
				<p:blockUI block="gridData1" trigger="gridData1" />
				<p:dataTable id="listGrupo" value="#{setorBean.listaGrupoExib}"
					paginator="true" rows="6" var="liGrupo">

					<p:column headerText="Codigo do Grupo">
						<h:outputText value="#{liGrupo.idGrupo}" />
					</p:column>

					<p:column headerText="Descrição do Grupo">
						<h:outputText value="#{liGrupo.descricao}" />
					</p:column>

					<p:column headerText="Excluir">
						<p:commandLink id="linkExcluir" value="Excluir" ajax="dialog2"
							action="#{setorBean.remGru}" update="data1">
							<f:setPropertyActionListener value="#{liGrupo.idGrupo}"
								target="#{setorBean.idGrup}" />
						</p:commandLink>
					</p:column>

				</p:dataTable>
				<p:blockUI block="listGrupo" trigger="listGrupo">
        				LOADING<br />
					<p:graphicImage name="ajaxloader.gif" />
				</p:blockUI>
			</h:panelGrid>

			<p:dialog id="dialog2" header="Grupo" widgetVar="dlg2" modal="true"
				height="100" width="400">

				<h:panelGrid id="gridGru" columns="2" columnClasses="label, value">
				
					Grupo:
					<p:selectOneMenu id="setorChk" style="width:265px;"
						value="#{setorBean.grupo}">
						<f:selectItem itemLabel="Selecione um Grupo" />
						<f:selectItems value="#{setorBean.listaGrupo}" var="lisGrupo"
							itemValue="#{lisGrupo}"
							itemLabel="#{lisGrupo.idGrupo} - #{lisGrupo.descricao}" />
					</p:selectOneMenu>

				</h:panelGrid>

				<p:tooltip id="toolTipAliq" for="setorChk"
					value="Exibição 'Código' - 'Descrição'" showEffect="clip"
					hideEffect="explode" />

				<p:commandButton id="btnIncluir" value="Incluir"
					actionListener="#{setorBean.incluirGrup}"
					update="setorChk, gridData1" />
			</p:dialog>
		</div>
	</h:form>
</body>
</html>
